package com.buding.fx.base.juc.cdl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.UUID;
import java.util.concurrent.CountDownLatch;

public class CompanyContractTask implements Runnable{
    Logger logger = LoggerFactory.getLogger(CompanyContractTask.class);

    CountDownLatch countDownLatch;
    String companyName;
    String contractNo;
    String orderId;

    public CompanyContractTask(CountDownLatch countDownLatch, String companyName, String contractNo) {
        this.countDownLatch = countDownLatch;
        this.companyName = companyName;
        this.contractNo = contractNo;
    }

    public String getOrderId(){
        return orderId;
    }

    @Override
    public void run() {
        logger.info("{} 签署合同",companyName);
        try {
            Thread.sleep(3000);
            logger.info("{} 合同签署完成",contractNo);
            this.orderId = UUID.randomUUID()+"";
            countDownLatch.countDown();
            logger.info("{} 合同流程签署结束!!!",companyName);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
